<!--
 * @Descripttion: 
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-21 16:25:23
 * @LastEditTime: 2022-11-08 11:43:04
-->
<template>
  <dt-modal-edit ref="edit" title="交房管理" @ok="submitFun" :label-width="120" :transfer="true">

  </dt-modal-edit>
</template>
<script>
  import comMgr from '@/biz/sales/salesCommon'
  import ParamsDelivery from './delivery.js'
  export default {
    data() {
      return {
        // '签约回款中', '签约已全款' 可交房操作
        contractId: '',
        deliveryForm: {
          workNo: null,
          handRoomDate: '',
          divideInto: null,
          divideType: '1', // 交房人类别
          contractorId: '',
        }
      }
    },
    mounted() {},
    methods: {
      show(contractId, isEdit, divideRooms) {
        this.contractId = contractId
        if (isEdit) {
          divideRooms[0].divideType = divideRooms[0].isCurrentCounselor ? '1' : '0'
          this.deliveryForm = { ...divideRooms[0] }
        } else {
          this.deliveryForm = {
            workNo: null,
            handRoomDate: '',
            divideInto: null,
            divideType: '1', // 交房人类别
            contractorId: ''
          }
        }
        this.$refs.edit.show(new ParamsDelivery(this).options(), this.deliveryForm)
      },
      submitFun() {
        let params = Object.assign(this.deliveryForm, {
          contractId: this.contractId,
        })
        params.isCurrentCounselor = params.divideType == '1' ? true : false

        comMgr
          .getHouseDelivery(params)
          .then((res) => {
            this.$refs.edit.hide()
            this.$emit('onGetOrderDetail')
          })
          .catch((res) => {})
      }
    },
  }
</script>
<style lang="scss" scoped>
  .delivery-msg {
    margin-top: 40px;

    .table-delivery {
      margin-top: 20px;
    }
  }
</style>